#pragma once
#ifndef HARDWARE_SERIAL_H
#define HARDWARE_SERIAL_H

#include <driver/uart.h>

#ifdef __cplusplus
#include <string>

class HardwareSerial
{
private:
    uart_port_t uart_num = UART_NUM_0;
    size_t uart_buffer_size = 1024 * 2;
    int baud_rate;
    void send(const std::string &str);
    HardwareSerial()
    {
    }

public:
    static HardwareSerial &getInstance()
    {
        static HardwareSerial instance; // 静态局部变量，保证唯一性
        return instance;
    }
    void begin(int baud_rate = 115200);
    void print(const std::string &str);
    void println(const std::string &str);
    bool available();
    char read();
    std::string readString();
};

extern HardwareSerial &Serial;

#endif
#endif